package app.itgungnir.compose.wan.business.coin_manifest

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import androidx.paging.compose.collectAsLazyPagingItems
import androidx.paging.compose.items
import app.itgungnir.compose.wan.widgets.WanPagingList
import app.itgungnir.compose.wan.widgets.WanScaffold
import com.google.accompanist.insets.navigationBarsPadding

@Composable
fun CoinManifestScreen(navController: NavController = rememberNavController()) {
    val viewModel = viewModel<CoinManifestViewModel>()
    // UI
    WanScaffold(
        modifier = Modifier.navigationBarsPadding(),
        title = "积分明细",
        navController = navController
    ) {
        val pagingItems = viewModel.dataFlow.collectAsLazyPagingItems()
        WanPagingList(pagingItems = pagingItems) {
            items(pagingItems) {
                CoinManifestItem(item = it)
            }
        }
    }
}
